home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / ipworks / udptime.fr_ / udptime.fr (.txt)
Encoding:
Visual Basic Form  |  1996-03-13  |  2.6 KB  |  80 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Time Service Broadcast"
  5.    ClientHeight    =   4560
  6.    ClientLeft      =   1350
  7.    ClientTop       =   1590
  8.    ClientWidth     =   6660
  9.    Height          =   4965
  10.    Left            =   1290
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4560
  13.    ScaleWidth      =   6660
  14.    Top             =   1245
  15.    Width           =   6780
  16.    Begin UDPPORT UDPPort1 
  17.       Height          =   420
  18.       InBufferSize    =   2048
  19.       Left            =   4320
  20.       LocalPort       =   0
  21.       MaxPacketSize   =   2048
  22.       OutBufferSize   =   2048
  23.       RegHandle       =   UDPTIME.FRX:0000
  24.       RemoteHost      =   ""
  25.       RemotePort      =   0
  26.       Top             =   240
  27.       UseConnection   =   0   'False
  28.       Width           =   420
  29.       WinsockLoaded   =   0   'False
  30.    End
  31.    Begin ListBox lResponse 
  32.       Height          =   3735
  33.       Left            =   0
  34.       TabIndex        =   0
  35.       Top             =   720
  36.       Width           =   6615
  37.    End
  38.    Begin CommandButton bLookUp 
  39.       Caption         =   "Look Up!!"
  40.       Default         =   -1  'True
  41.       Height          =   320
  42.       Left            =   4920
  43.       TabIndex        =   1
  44.       Top             =   120
  45.       Width           =   1455
  46.    End
  47.    Begin Label Label1 
  48.       BackStyle       =   0  'Transparent
  49.       Caption         =   "Clicking on the button will broadcast a request on the DAYTIME port on all the hosts on your LAN.  Their times will be shown in the list below."
  50.       ForeColor       =   &H00800000&
  51.       Height          =   675
  52.       Left            =   120
  53.       TabIndex        =   2
  54.       Top             =   0
  55.       Width           =   4335
  56.    End
  57. Sub bLookUp_Click ()
  58. UDPPort1.WinsockLoaded = True
  59. UDPPort1.RemoteHost = "255.255.255.255"
  60. UDPPort1.RemotePort = 13 'daytime service
  61. lResponse.Clear
  62. If Not UDPPort1.Active Then UDPPort1.Active = True
  63. 'send anything and the server will send the time
  64. UDPPort1.DataToSend = "hello?"
  65. End Sub
  66. Sub Form_Resize ()
  67. If WindowState <> 1 Then
  68.     margin% = lResponse.Left
  69.     lResponse.Width = ScaleWidth - 2 * margin%
  70.     lResponse.Height = ScaleHeight - lResponse.Top - margin%
  71. End If
  72. End Sub
  73. Sub UDPPort1_DataIn (Datagram As String, SourceAddress As String, SourcePort As Integer)
  74. 'first do some cleanup...
  75. Do While Asc(Right$(Datagram, 1)) < 32
  76.     Datagram = Left$(Datagram, Len(Datagram) - 1)
  77. 'then show the time
  78. lResponse.AddItem SourceAddress & Chr$(9) & Datagram
  79. End Sub
  80.